﻿//----------------------------------------------------------------------------------------
// Copyright (C) 2008  银龙小子 版权所有。
//
// 文件编号：      
// 文 件 名：      BuildClassCommon.cs
// 文件功能描述：   编译数据访问层
//
// 创建标识：      毛才君    2008-3-22 13:01:03
//
// 修改标识：
// 修改描述：
// 
// 修改标识：
// 修改描述：
//----------------------------------------------------------------------------------------

using System.CodeDom;

namespace MaoCaiJun.DataBase.BuildProviders.BuildClass
{
    abstract class  BuildClassCommon
    {
        protected CodeTypeDeclaration ctd = null;//生成类
        protected MaoCaiJun.DataBase.Configuration.DbsAnalysis.Class _dbsAnalysisClass;

        public BuildClassCommon(MaoCaiJun.DataBase.Configuration.DbsAnalysis.Class _dbsAnalysisClass, MaoCaiJun.DataBase.Sys.Data.SqlType _dataType)
        {
            this._dbsAnalysisClass = _dbsAnalysisClass;
            ctd = new CodeTypeDeclaration();//生成类 
            #region 构造函数
            //默认构造函数
            CodeTypeConstructor defaultConstructor = new CodeTypeConstructor();
            defaultConstructor.Comments.Add(new CodeCommentStatement("<summary>", true));
            defaultConstructor.Comments.Add(new CodeCommentStatement("类 " + _dbsAnalysisClass.Name + " 的默认构造函数", true));
            defaultConstructor.Comments.Add(new CodeCommentStatement("</summary>", true));
            defaultConstructor.Attributes = Config.MemberAttribute;
            defaultConstructor.Statements.Add(new CodeSnippetExpression("MaoCaiJun.DataBase.Sys.Common.Log.Info(\"类 " + _dbsAnalysisClass.Name + " 静态构造函数初始化\")"));
            defaultConstructor.Statements.Add(new CodeSnippetExpression("CreateTable()"));
            ctd.Members.Add(defaultConstructor);

            #endregion
            #region 生成类
            ctd.Name = _dbsAnalysisClass.Name;

            ctd.Comments.Add(new CodeCommentStatement("----------------------------------------------------------------------------------------", false));
            //ctd.Comments.Add(new CodeCommentStatement(" Copyright (C) " + System.DateTime.Today.Year + "  毛才君 版权所有。", false));
            ctd.Comments.Add(new CodeCommentStatement(" 文件编号：      ", false));
            ctd.Comments.Add(new CodeCommentStatement(" 文 件 名：      ", false));
            ctd.Comments.Add(new CodeCommentStatement(" 文件功能描述：  " + _dbsAnalysisClass.Name + " 的数据访问类", false));
            ctd.Comments.Add(new CodeCommentStatement("", false));
            ctd.Comments.Add(new CodeCommentStatement(" 创建标识：      MaoCaiJun.DataBase 代码辅助工具  (毛才君)    " + System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "", false));
            ctd.Comments.Add(new CodeCommentStatement("", false));
            ctd.Comments.Add(new CodeCommentStatement(" 修改标识：", false));
            ctd.Comments.Add(new CodeCommentStatement(" 修改描述：", false));
            ctd.Comments.Add(new CodeCommentStatement("", false));
            ctd.Comments.Add(new CodeCommentStatement(" 修改标识：", false));
            ctd.Comments.Add(new CodeCommentStatement(" 修改描述：", false));
            ctd.Comments.Add(new CodeCommentStatement("----------------------------------------------------------------------------------------", false));
            ctd.IsClass = true;
            ctd.IsPartial = true;
            ctd.Attributes = MemberAttributes.Private | MemberAttributes.Static;
            //生成类注释
            ctd.Comments.Add(new CodeCommentStatement("<summary>", true));
            ctd.Comments.Add(new CodeCommentStatement("数据访问类 " + _dbsAnalysisClass.Summary, true));
            ctd.Comments.Add(new CodeCommentStatement("</summary>", true));
            ctd.CustomAttributes.Add(new CodeAttributeDeclaration(new CodeTypeReference(typeof(System.ComponentModel.DataObjectAttribute))));
            #endregion
            #region 静态属性
            #region TableName 属性
            CodeMemberProperty propertyTableName = new CodeMemberProperty();
            propertyTableName.Comments.Add(new CodeCommentStatement("<summary>", true));
            propertyTableName.Comments.Add(new CodeCommentStatement("数据表的名称", true));
            propertyTableName.Comments.Add(new CodeCommentStatement("</summary>", true));
            propertyTableName.Attributes = Config.MemberAttribute | MemberAttributes.Static;
            propertyTableName.Type = new CodeTypeReference(typeof(string));
            propertyTableName.Name = "TableName";
            if (string.IsNullOrEmpty(_dbsAnalysisClass.TableNameInterface))
            {
                propertyTableName.GetStatements.Add(new CodeMethodReturnStatement(new CodeSnippetExpression("\"" + _dbsAnalysisClass.Table + "\"")));
            }
            else
            {
                //return Type.GetType("").GetConstructor(System.Type.EmptyTypes).Invoke(new string[] { "WMS_Stock" }).ToString();
                propertyTableName.GetStatements.Add(new CodeMethodReturnStatement(new CodeSnippetExpression("System.Type.GetType(\"" + _dbsAnalysisClass.TableNameInterface.Split('|')[0] + "\", true, true).GetMethod(\"" + _dbsAnalysisClass.TableNameInterface.Split('|')[1] + "\").Invoke(null, new String[] { \"" + _dbsAnalysisClass.Table + "\" }).ToString()")));
            }
            ctd.Members.Add(propertyTableName);
            #endregion TableName 属性
            #region 数据库类型
            CodeMemberProperty dataType = new CodeMemberProperty();
            dataType.Comments.Add(new CodeCommentStatement("<summary>", true));
            dataType.Comments.Add(new CodeCommentStatement("数据库类型", true));
            dataType.Comments.Add(new CodeCommentStatement("</summary>", true));
            dataType.Attributes = Config.MemberAttribute | MemberAttributes.Static;
            dataType.Type = new CodeTypeReference("MaoCaiJun.DataBase.Sys.Data.SqlType");
            dataType.Name = "DataType";
            dataType.GetStatements.Add(new CodeMethodReturnStatement(new CodeSnippetExpression("MaoCaiJun.DataBase.Sys.Data.SqlType." + _dataType)));
            ctd.Members.Add(dataType);
            #endregion 数据库类型
            #region 数据库连接位置
            CodeMemberProperty connectionLocation = new CodeMemberProperty();
            connectionLocation.Comments.Add(new CodeCommentStatement("<summary>", true));
            connectionLocation.Comments.Add(new CodeCommentStatement("数据库连接位置", true));
            connectionLocation.Comments.Add(new CodeCommentStatement("</summary>", true));
            connectionLocation.Attributes = Config.MemberAttribute | MemberAttributes.Static;
            connectionLocation.Type = new CodeTypeReference(typeof(MaoCaiJun.DataBase.Sys.Data.ConnectionLocation));
            connectionLocation.Name = "ConnectionLocation";
            connectionLocation.GetStatements.Add(new CodeMethodReturnStatement(new CodeSnippetExpression("MaoCaiJun.DataBase.Sys.Data.ConnectionLocation." + _dbsAnalysisClass.ConnectionLocation.ToString())));
            ctd.Members.Add(connectionLocation);
            #endregion 数据库连接位置
            #region 数据库连接字符串
            CodeMemberProperty connectionString = new CodeMemberProperty();
            connectionString.Comments.Add(new CodeCommentStatement("<summary>", true));
            connectionString.Comments.Add(new CodeCommentStatement("数据库类型", true));
            connectionString.Comments.Add(new CodeCommentStatement("</summary>", true));
            connectionString.Attributes = Config.MemberAttribute | MemberAttributes.Static;
            connectionString.Type = new CodeTypeReference(typeof(string));
            connectionString.Name = "ConnectionString";
            connectionString.GetStatements.Add(new CodeMethodReturnStatement(new CodeSnippetExpression("\"" + _dbsAnalysisClass.ConnectionString + "\"")));
            ctd.Members.Add(connectionString);
            #endregion 数据库连接字符串
            #region Database 字段
            CodeMemberField database_ = new CodeMemberField();
            database_.Comments.Add(new CodeCommentStatement("<summary>", true));
            database_.Comments.Add(new CodeCommentStatement("Database数据处理对象", true));
            database_.Comments.Add(new CodeCommentStatement("</summary>", true));
            database_.Type = new CodeTypeReference("MaoCaiJun.DataBase.Sys.Data.Database");
            //database_.Name = "database_ = MaoCaiJun.DataBase.Sys.Data.DatabaseFactory.GetDatabase(DataType,ConnectionLocation,ConnectionString)";
            database_.Name = "database_ = null";
            database_.Attributes = MemberAttributes.Private | MemberAttributes.Static;
            ctd.Members.Add(database_);
            #endregion Database 字段
            #region Database 属性
            CodeMemberProperty database = new CodeMemberProperty();
            database.Comments.Add(new CodeCommentStatement("<summary>", true));
            database.Comments.Add(new CodeCommentStatement("Database数据处理对象", true));
            database.Comments.Add(new CodeCommentStatement("</summary>", true));
            database.Attributes = Config.MemberAttribute | MemberAttributes.Static;
            database.Type = new CodeTypeReference("MaoCaiJun.DataBase.Sys.Data.Database");
            database.Name = "Database";
            database.GetStatements.Add(new CodeSnippetStatement("if(" + _dbsAnalysisClass.Name + ".database_ == null){" + _dbsAnalysisClass.Name + ".database_ = MaoCaiJun.DataBase.Sys.Data.DatabaseFactory.GetDatabase(DataType,ConnectionLocation,ConnectionString);}"));
            database.GetStatements.Add(new CodeMethodReturnStatement(new CodeFieldReferenceExpression(new CodeSnippetExpression(_dbsAnalysisClass.Name), "database_")));
            ctd.Members.Add(database);
            #endregion Database 属性
            #region EnumDbTypeDictionary 字段
            CodeMemberField enumDbTypeDictionary_ = new CodeMemberField();
            enumDbTypeDictionary_.Comments.Add(new CodeCommentStatement("<summary>", true));
            enumDbTypeDictionary_.Comments.Add(new CodeCommentStatement("表字段类型集合", true));
            enumDbTypeDictionary_.Comments.Add(new CodeCommentStatement("</summary>", true));
            enumDbTypeDictionary_.Type = new CodeTypeReference("System.Collections.Generic.Dictionary<" + _dbsAnalysisClass.Name + "Enum, System.Data.DbType>");
            enumDbTypeDictionary_.Name = "enumDbTypeDictionary_ = null";
            enumDbTypeDictionary_.Attributes = MemberAttributes.Private | MemberAttributes.Static;
            ctd.Members.Add(enumDbTypeDictionary_);
            #endregion EnumDbTypeDictionary 字段
            #region EnumDbTypeDictionary 属性
            CodeMemberProperty enumDbTypeDictionary = new CodeMemberProperty();
            enumDbTypeDictionary.Comments.Add(new CodeCommentStatement("<summary>", true));
            enumDbTypeDictionary.Comments.Add(new CodeCommentStatement("表字段类型集合", true));
            enumDbTypeDictionary.Comments.Add(new CodeCommentStatement("</summary>", true));
            enumDbTypeDictionary.Attributes = Config.MemberAttribute | MemberAttributes.Static;
            enumDbTypeDictionary.Type = new CodeTypeReference("System.Collections.Generic.Dictionary<" + _dbsAnalysisClass.Name + "Enum, System.Data.DbType>");
            enumDbTypeDictionary.Name = "EnumDbTypeDictionary";
            string enumDbTypeString = "enumDbTypeDictionary_.Add(" + _dbsAnalysisClass.Name + "Enum." + _dbsAnalysisClass.ID.Name + "," + GetDbType(_dbsAnalysisClass.ID.Type) + ");\r\n";
            foreach (MaoCaiJun.DataBase.Configuration.DbsAnalysis.Property item in _dbsAnalysisClass.Property)
            {
                enumDbTypeString += "enumDbTypeDictionary_.Add(" + _dbsAnalysisClass.Name + "Enum." + item.Name + "," + GetDbType(item.Type) + ");\r\n";
            }
            enumDbTypeDictionary.GetStatements.Add(new CodeSnippetStatement("if(" + _dbsAnalysisClass.Name + ".enumDbTypeDictionary_ == null){" + _dbsAnalysisClass.Name + ".enumDbTypeDictionary_ = new System.Collections.Generic.Dictionary<" + _dbsAnalysisClass.Name + "Enum, System.Data.DbType>();\r\n" +
                enumDbTypeString +
                "}"));
            enumDbTypeDictionary.GetStatements.Add(new CodeMethodReturnStatement(new CodeFieldReferenceExpression(new CodeSnippetExpression(_dbsAnalysisClass.Name), "enumDbTypeDictionary_")));
            ctd.Members.Add(enumDbTypeDictionary);
            #endregion EnumDbTypeDictionary 属性
            #endregion
            #region 静态方法
            #region 插入一条数据
            CodeMemberMethod MethodInsert = new CodeMemberMethod();
            MethodInsert.Comments.Add(new CodeCommentStatement("<summary>", true));
            MethodInsert.Comments.Add(new CodeCommentStatement("插入一条数据", true));
            MethodInsert.Comments.Add(new CodeCommentStatement("</summary>", true));
            MethodInsert.Comments.Add(new CodeCommentStatement("<param name=\"model\">实体</param>", true));
            MethodInsert.Comments.Add(new CodeCommentStatement("<returns>影响的行数</returns>", true));
            MethodInsert.CustomAttributes.Add(new CodeAttributeDeclaration(new CodeTypeReference(typeof(System.ComponentModel.DataObjectMethodAttribute)), new System.CodeDom.CodeAttributeArgument(new System.CodeDom.CodeArgumentReferenceExpression("System.ComponentModel.DataObjectMethodType.Insert , true"))));
            MethodInsert.Name = string.Format(Config.DbMemberMethodInsert, _dbsAnalysisClass.Name);
            MethodInsert.Attributes = Config.MemberAttribute | MemberAttributes.Static;
            MethodInsert.Parameters.Add(new CodeParameterDeclarationExpression(_dbsAnalysisClass.Name, "model"));
            MethodInsert.ReturnType = new CodeTypeReference(typeof(int));
            MethodInsert.Statements.Add(new CodeSnippetExpression("return " + MethodInsert.Name + "(model,null)"));
            ctd.Members.Add(MethodInsert);
            #endregion 插入一条数据
            #region 更新一条数据
            CodeMemberMethod MethodUpdate = new CodeMemberMethod();
            MethodUpdate.Comments.Add(new CodeCommentStatement("<summary>", true));
            MethodUpdate.Comments.Add(new CodeCommentStatement("更新一条数据", true));
            MethodUpdate.Comments.Add(new CodeCommentStatement("</summary>", true));
            MethodUpdate.Comments.Add(new CodeCommentStatement("<param name=\"model\">实体</param>", true));
            MethodUpdate.Comments.Add(new CodeCommentStatement("<returns>影响的行数</returns>", true));
            MethodUpdate.CustomAttributes.Add(new CodeAttributeDeclaration(new CodeTypeReference(typeof(System.ComponentModel.DataObjectMethodAttribute)), new System.CodeDom.CodeAttributeArgument(new System.CodeDom.CodeArgumentReferenceExpression("System.ComponentModel.DataObjectMethodType.Update , true"))));
            MethodUpdate.Name = string.Format(Config.DbMemberMethodUpdate, _dbsAnalysisClass.Name);
            MethodUpdate.Attributes = Config.MemberAttribute | MemberAttributes.Static;
            MethodUpdate.Parameters.Add(new CodeParameterDeclarationExpression(_dbsAnalysisClass.Name, "model"));
            MethodUpdate.ReturnType = new CodeTypeReference(typeof(int));
            MethodUpdate.Statements.Add(new CodeSnippetExpression("return " + MethodUpdate.Name + "(model,null)"));
            ctd.Members.Add(MethodUpdate);
            #endregion 更新一条数据
            #region 插入或更新一条数据
            CodeMemberMethod MethodInsertUpdate = new CodeMemberMethod();
            MethodInsertUpdate.Comments.Add(new CodeCommentStatement("<summary>", true));
            MethodInsertUpdate.Comments.Add(new CodeCommentStatement("插入或更新一条数据", true));
            MethodInsertUpdate.Comments.Add(new CodeCommentStatement("</summary>", true));
            MethodInsertUpdate.Comments.Add(new CodeCommentStatement("<param name=\"model\">实体</param>", true));
            MethodInsertUpdate.Comments.Add(new CodeCommentStatement("<returns>影响的行数</returns>", true));
            MethodInsertUpdate.Name = string.Format(Config.DbMemberMethodInsertUpdate, _dbsAnalysisClass.Name);
            MethodInsertUpdate.Attributes = Config.MemberAttribute | MemberAttributes.Static;
            MethodInsertUpdate.Parameters.Add(new CodeParameterDeclarationExpression(_dbsAnalysisClass.Name, "model"));
            MethodInsertUpdate.ReturnType = new CodeTypeReference(typeof(int));
            MethodInsertUpdate.Statements.Add(new CodeSnippetExpression("return " + MethodInsertUpdate.Name + "(model,null)"));
            ctd.Members.Add(MethodInsertUpdate);
            #endregion 插入或更新一条数据
            #region 根据编号删除数据
            CodeMemberMethod MethodDeleteByIndex = new CodeMemberMethod();
            MethodDeleteByIndex.Comments.Add(new CodeCommentStatement("<summary>", true));
            MethodDeleteByIndex.Comments.Add(new CodeCommentStatement("根据编号删除数据", true));
            MethodDeleteByIndex.Comments.Add(new CodeCommentStatement("</summary>", true));
            MethodDeleteByIndex.Comments.Add(new CodeCommentStatement("<param name=\"" + _dbsAnalysisClass.ID.Name + "\">栏目id</param>", true));
            MethodDeleteByIndex.Comments.Add(new CodeCommentStatement("<returns>影响的行数</returns>", true));
            MethodDeleteByIndex.CustomAttributes.Add(new CodeAttributeDeclaration(new CodeTypeReference(typeof(System.ComponentModel.DataObjectMethodAttribute)), new System.CodeDom.CodeAttributeArgument(new System.CodeDom.CodeArgumentReferenceExpression("System.ComponentModel.DataObjectMethodType.Delete , false"))));
            MethodDeleteByIndex.Name = string.Format(Config.DbMemberMethodDeleteByIndex, _dbsAnalysisClass.Name);
            MethodDeleteByIndex.Attributes = Config.MemberAttribute | MemberAttributes.Static;
            MethodDeleteByIndex.Parameters.Add(new CodeParameterDeclarationExpression(_dbsAnalysisClass.ID.Type, _dbsAnalysisClass.ID.Name));
            MethodDeleteByIndex.ReturnType = new CodeTypeReference(typeof(int));
            MethodDeleteByIndex.Statements.Add(new CodeSnippetExpression("return " + MethodDeleteByIndex.Name + "(" + _dbsAnalysisClass.ID.Name + ",null)"));
            ctd.Members.Add(MethodDeleteByIndex);
            #endregion 根据编号删除数据
            #region 根据对象删除数据
            CodeMemberMethod MethodDeleteByModel1 = new CodeMemberMethod();
            MethodDeleteByModel1.Comments.Add(new CodeCommentStatement("<summary>", true));
            MethodDeleteByModel1.Comments.Add(new CodeCommentStatement("根据对象删除数据", true));
            MethodDeleteByModel1.Comments.Add(new CodeCommentStatement("</summary>", true));
            MethodDeleteByModel1.Comments.Add(new CodeCommentStatement("<param name=\"model\">实体</param>", true));
            MethodDeleteByModel1.Comments.Add(new CodeCommentStatement("<returns>影响的行数</returns>", true));
            MethodDeleteByModel1.CustomAttributes.Add(new CodeAttributeDeclaration(new CodeTypeReference(typeof(System.ComponentModel.DataObjectMethodAttribute)), new System.CodeDom.CodeAttributeArgument(new System.CodeDom.CodeArgumentReferenceExpression("System.ComponentModel.DataObjectMethodType.Delete , true"))));
            MethodDeleteByModel1.Name = string.Format(Config.DbMemberMethodDeleteByIndex, _dbsAnalysisClass.Name);
            MethodDeleteByModel1.Attributes = Config.MemberAttribute | MemberAttributes.Static;
            MethodDeleteByModel1.Parameters.Add(new CodeParameterDeclarationExpression(_dbsAnalysisClass.Name, "model"));
            MethodDeleteByModel1.ReturnType = new CodeTypeReference(typeof(int));
            MethodDeleteByModel1.Statements.Add(new CodeSnippetExpression("return " + MethodDeleteByIndex.Name + "(model." + _dbsAnalysisClass.ID.Name + ",null)"));
            ctd.Members.Add(MethodDeleteByModel1);
            #endregion 根据对象删除数据
            #region 根据对象删除数据
            CodeMemberMethod MethodDeleteByModel2 = new CodeMemberMethod();
            MethodDeleteByModel2.Comments.Add(new CodeCommentStatement("<summary>", true));
            MethodDeleteByModel2.Comments.Add(new CodeCommentStatement("根据对象删除数据", true));
            MethodDeleteByModel2.Comments.Add(new CodeCommentStatement("</summary>", true));
            MethodDeleteByModel2.Comments.Add(new CodeCommentStatement("<param name=\"model\">实体</param>", true));
            MethodDeleteByModel2.Comments.Add(new CodeCommentStatement("<param name=\"dbTransaction\">事务</param>", true));
            MethodDeleteByModel2.Comments.Add(new CodeCommentStatement("<returns>影响的行数</returns>", true));
            MethodDeleteByModel2.Name = string.Format(Config.DbMemberMethodDeleteByIndex, _dbsAnalysisClass.Name);
            MethodDeleteByModel2.Attributes = Config.MemberAttribute | MemberAttributes.Static;
            MethodDeleteByModel2.Parameters.Add(new CodeParameterDeclarationExpression(_dbsAnalysisClass.Name, "model"));
            MethodDeleteByModel2.Parameters.Add(new CodeParameterDeclarationExpression(typeof(System.Data.Common.DbTransaction), "dbTransaction"));
            MethodDeleteByModel2.ReturnType = new CodeTypeReference(typeof(int));
            MethodDeleteByModel2.Statements.Add(new CodeSnippetExpression("return " + MethodDeleteByIndex.Name + "(model." + _dbsAnalysisClass.ID.Name + ",dbTransaction)"));
            ctd.Members.Add(MethodDeleteByModel2);
            #endregion 根据对象删除数据
            #region 根据条件删除数据
            CodeMemberMethod MethodDeleteByWhere = new CodeMemberMethod();
            MethodDeleteByWhere.Comments.Add(new CodeCommentStatement("<summary>", true));
            MethodDeleteByWhere.Comments.Add(new CodeCommentStatement("根据条件删除数据", true));
            MethodDeleteByWhere.Comments.Add(new CodeCommentStatement("</summary>", true));
            MethodDeleteByWhere.Comments.Add(new CodeCommentStatement("<param name=\"strWhere\">删除条件</param>", true));
            MethodDeleteByWhere.Comments.Add(new CodeCommentStatement("<example>例:<code>[id]=1 and [name]='mccj'</code></example>", true));
            MethodDeleteByWhere.Comments.Add(new CodeCommentStatement("<returns>影响的行数</returns>", true));
            MethodDeleteByWhere.CustomAttributes.Add(new CodeAttributeDeclaration(new CodeTypeReference(typeof(System.ComponentModel.DataObjectMethodAttribute)), new System.CodeDom.CodeAttributeArgument(new System.CodeDom.CodeArgumentReferenceExpression("System.ComponentModel.DataObjectMethodType.Delete , false"))));
            MethodDeleteByWhere.Name = string.Format(Config.DbMemberMethodDeleteDynamic, _dbsAnalysisClass.Name);
            MethodDeleteByWhere.Attributes = Config.MemberAttribute | MemberAttributes.Static;
            MethodDeleteByWhere.Parameters.Add(new CodeParameterDeclarationExpression(typeof(string), "strWhere"));
            MethodDeleteByWhere.ReturnType = new CodeTypeReference(typeof(int));
            MethodDeleteByWhere.Statements.Add(new CodeSnippetExpression("return " + MethodDeleteByWhere.Name + "(strWhere,null)"));
            ctd.Members.Add(MethodDeleteByWhere);
            #endregion 根据条件删除数据
            #region 根据编号得到一个对象实体1
            CodeMemberMethod MethodGet = new CodeMemberMethod();
            MethodGet.Comments.Add(new CodeCommentStatement("<summary>", true));
            MethodGet.Comments.Add(new CodeCommentStatement("根据编号得到一个对象实体", true));
            MethodGet.Comments.Add(new CodeCommentStatement("</summary>", true));
            MethodGet.Comments.Add(new CodeCommentStatement("<param name=\"" + _dbsAnalysisClass.ID.Name + "\">栏目id</param>", true));
            MethodGet.Comments.Add(new CodeCommentStatement("<returns>影响的行数</returns>", true));
            MethodGet.CustomAttributes.Add(new CodeAttributeDeclaration(new CodeTypeReference(typeof(System.ComponentModel.DataObjectMethodAttribute)), new System.CodeDom.CodeAttributeArgument(new System.CodeDom.CodeArgumentReferenceExpression("System.ComponentModel.DataObjectMethodType.Select , true"))));
            MethodGet.Name = string.Format(Config.DbMemberMethodGet, _dbsAnalysisClass.Name);
            MethodGet.Attributes = Config.MemberAttribute | MemberAttributes.Static;
            MethodGet.Parameters.Add(new CodeParameterDeclarationExpression(_dbsAnalysisClass.ID.Type, _dbsAnalysisClass.ID.Name));
            MethodGet.ReturnType = new CodeTypeReference(_dbsAnalysisClass.Name);
            MethodGet.Statements.Add(new CodeSnippetExpression("return " + MethodGet.Name + "(" + _dbsAnalysisClass.ID.Name + ",null as System.Data.Common.DbTransaction)"));
            ctd.Members.Add(MethodGet);
            #endregion 根据编号得到一个对象实体1
            #region 根据编号得到一个对象实体2
            CodeMemberMethod MethodGet2 = new CodeMemberMethod();
            MethodGet2.Comments.Add(new CodeCommentStatement("<summary>", true));
            MethodGet2.Comments.Add(new CodeCommentStatement("根据编号得到一个对象实体", true));
            MethodGet2.Comments.Add(new CodeCommentStatement("</summary>", true));
            MethodGet2.Comments.Add(new CodeCommentStatement("<param name=\"e\">枚举</param>", true));
            MethodGet2.Comments.Add(new CodeCommentStatement("<param name=\"" + _dbsAnalysisClass.ID.Name + "\">值</param>", true));
            MethodGet2.Comments.Add(new CodeCommentStatement("<returns>影响的行数</returns>", true));
            MethodGet2.CustomAttributes.Add(new CodeAttributeDeclaration(new CodeTypeReference(typeof(System.ComponentModel.DataObjectMethodAttribute)), new System.CodeDom.CodeAttributeArgument(new System.CodeDom.CodeArgumentReferenceExpression("System.ComponentModel.DataObjectMethodType.Select , true"))));
            MethodGet2.Name = string.Format(Config.DbMemberMethodGet, _dbsAnalysisClass.Name);
            MethodGet2.Attributes = Config.MemberAttribute | MemberAttributes.Static;
            MethodGet2.Parameters.Add(new CodeParameterDeclarationExpression(_dbsAnalysisClass.Name + "Enum", "e"));
            MethodGet2.Parameters.Add(new CodeParameterDeclarationExpression(typeof(object), _dbsAnalysisClass.ID.Name));
            MethodGet2.ReturnType = new CodeTypeReference(_dbsAnalysisClass.Name);
            MethodGet2.Statements.Add(new CodeSnippetExpression("return " + MethodGet2.Name + "(e," + _dbsAnalysisClass.ID.Name + ",null as System.Data.Common.DbTransaction)"));
            ctd.Members.Add(MethodGet2);
            #endregion 根据编号得到一个对象实体2
            #region 根据编号得到一个对象实体3
            CodeMemberMethod MethodGet3 = new CodeMemberMethod();
            MethodGet3.Comments.Add(new CodeCommentStatement("<summary>", true));
            MethodGet3.Comments.Add(new CodeCommentStatement("根据编号得到一个对象实体", true));
            MethodGet3.Comments.Add(new CodeCommentStatement("</summary>", true));
            MethodGet3.Comments.Add(new CodeCommentStatement("<param name=\"" + _dbsAnalysisClass.ID.Name + "\">编号</param>", true));
            MethodGet3.Comments.Add(new CodeCommentStatement("<param name=\"dbTransaction\">事务</param>", true));
            MethodGet3.Name = string.Format(Config.DbMemberMethodGet, _dbsAnalysisClass.Name);
            MethodGet3.Attributes = Config.MemberAttribute | MemberAttributes.Static;
            MethodGet3.Parameters.Add(new CodeParameterDeclarationExpression(_dbsAnalysisClass.ID.Type, _dbsAnalysisClass.ID.Name));
            MethodGet3.Parameters.Add(new CodeParameterDeclarationExpression(typeof(System.Data.Common.DbTransaction), "dbTransaction"));
            MethodGet3.ReturnType = new CodeTypeReference(_dbsAnalysisClass.Name);
            MethodGet3.Statements.Add(new CodeSnippetExpression("return " + MethodGet3.Name + "(" + _dbsAnalysisClass.Name + "Enum." + _dbsAnalysisClass.ID.Name + "," + _dbsAnalysisClass.ID.Name + ",dbTransaction)"));
            ctd.Members.Add(MethodGet3);
            #endregion 根据编号得到一个对象实体3
            #region 根据编号得到一个对象实体4
            CodeMemberMethod MethodGet4 = new CodeMemberMethod();
            MethodGet4.Comments.Add(new CodeCommentStatement("<summary>", true));
            MethodGet4.Comments.Add(new CodeCommentStatement("根据编号得到一个对象实体", true));
            MethodGet4.Comments.Add(new CodeCommentStatement("</summary>", true));
            MethodGet4.Comments.Add(new CodeCommentStatement("<param name=\"strWhere\">查询条件</param>", true));
            //MethodGet4.Comments.Add(new CodeCommentStatement("<param name=\"strOrder\">排序条件</param>", true));
            MethodGet4.Name = string.Format(Config.DbMemberMethodGetWhere, _dbsAnalysisClass.Name);
            MethodGet4.Attributes = Config.MemberAttribute | MemberAttributes.Static;
            MethodGet4.Parameters.Add(new CodeParameterDeclarationExpression(typeof(string), "strWhere"));
            //MethodGet4.Parameters.Add(new CodeParameterDeclarationExpression(typeof(string), "strOrder"));
            MethodGet4.ReturnType = new CodeTypeReference(_dbsAnalysisClass.Name);
            MethodGet4.Statements.Add(new CodeSnippetExpression("return " + MethodGet4.Name + "(strWhere,null)"));
            ctd.Members.Add(MethodGet4);
            #endregion 根据编号得到一个对象实体4
            #region 根据条件获取相对属性的值(符合多个条件只返回第一条) 1
            CodeMemberMethod GetProperty1 = new CodeMemberMethod();
            GetProperty1.Comments.Add(new CodeCommentStatement("<summary>", true));
            GetProperty1.Comments.Add(new CodeCommentStatement("根据条件获取相对属性的值(符合多个条件只返回第一条)", true));
            GetProperty1.Comments.Add(new CodeCommentStatement("</summary>", true));
            GetProperty1.Comments.Add(new CodeCommentStatement("<param name=\"name\">条件属性</param>", true));
            GetProperty1.Comments.Add(new CodeCommentStatement("<param name=\"value\">条件值</param>", true));
            GetProperty1.Comments.Add(new CodeCommentStatement("<param name=\"targetField\">希望获取的属性</param>", true));
            GetProperty1.Comments.Add(new CodeCommentStatement("<returns>希望获取的属性的值</returns>", true));
            //GetProperty1.CustomAttributes.Add(new CodeAttributeDeclaration(new CodeTypeReference(typeof(System.ComponentModel.DataObjectMethodAttribute)), new System.CodeDom.CodeAttributeArgument(new System.CodeDom.CodeArgumentReferenceExpression("System.ComponentModel.DataObjectMethodType.Select , true"))));
            GetProperty1.Name = "GetProperty";
            GetProperty1.Attributes = Config.MemberAttribute | MemberAttributes.Static;
            GetProperty1.Parameters.Add(new CodeParameterDeclarationExpression(_dbsAnalysisClass.Name + "Enum", "name"));
            GetProperty1.Parameters.Add(new CodeParameterDeclarationExpression(typeof(object), "value"));
            GetProperty1.Parameters.Add(new CodeParameterDeclarationExpression(_dbsAnalysisClass.Name + "Enum", "targetField"));
            GetProperty1.ReturnType = new CodeTypeReference(typeof(object));
            GetProperty1.Statements.Add(new CodeSnippetExpression("return GetProperty(new " + _dbsAnalysisClass.Name + "Enum[] { name }, new object[] { value }, targetField)"));
            ctd.Members.Add(GetProperty1);
            #endregion 根据条件获取相对属性的值(符合多个条件只返回第一条) 1
            #region 根据条件获取相对属性的值(符合多个条件只返回第一条) 2
            CodeMemberMethod GetProperty2 = new CodeMemberMethod();
            GetProperty2.Comments.Add(new CodeCommentStatement("<summary>", true));
            GetProperty2.Comments.Add(new CodeCommentStatement("根据条件获取相对属性的值(符合多个条件只返回第一条)", true));
            GetProperty2.Comments.Add(new CodeCommentStatement("</summary>", true));
            GetProperty2.Comments.Add(new CodeCommentStatement("<param name=\"names\">条件属性</param>", true));
            GetProperty2.Comments.Add(new CodeCommentStatement("<param name=\"values\">条件值</param>", true));
            GetProperty2.Comments.Add(new CodeCommentStatement("<param name=\"targetField\">希望获取的属性</param>", true));
            GetProperty2.Comments.Add(new CodeCommentStatement("<returns>希望获取的属性的值</returns>", true));
            //GetProperty2.CustomAttributes.Add(new CodeAttributeDeclaration(new CodeTypeReference(typeof(System.ComponentModel.DataObjectMethodAttribute)), new System.CodeDom.CodeAttributeArgument(new System.CodeDom.CodeArgumentReferenceExpression("System.ComponentModel.DataObjectMethodType.Select , true"))));
            GetProperty2.Name = "GetProperty";
            GetProperty2.Attributes = Config.MemberAttribute | MemberAttributes.Static;
            GetProperty2.Parameters.Add(new CodeParameterDeclarationExpression(_dbsAnalysisClass.Name + "Enum[]", "names"));
            GetProperty2.Parameters.Add(new CodeParameterDeclarationExpression(typeof(object[]), "values"));
            GetProperty2.Parameters.Add(new CodeParameterDeclarationExpression(_dbsAnalysisClass.Name + "Enum", "targetField"));
            GetProperty2.ReturnType = new CodeTypeReference(typeof(object));
            GetProperty2.Statements.Add(new CodeSnippetExpression("string whereString = string.Empty"));
            GetProperty2.Statements.Add(new CodeSnippetStatement("if (names.Length == values.Length){"));
            GetProperty2.Statements.Add(new CodeSnippetStatement("for (int i = 0; i < names.Length; i++){"));
            GetProperty2.Statements.Add(new CodeSnippetStatement("if (values[i] == null){"));
            GetProperty2.Statements.Add(new CodeSnippetExpression("whereString += string.IsNullOrEmpty(whereString) ? \"\" : \" and \""));
            GetProperty2.Statements.Add(new CodeSnippetExpression("whereString += \" [\" + names[i] + \"] is null \""));
            GetProperty2.Statements.Add(new CodeSnippetStatement("}else {"));
            GetProperty2.Statements.Add(new CodeSnippetExpression("whereString += string.IsNullOrEmpty(whereString) ? \"\" : \" and \""));
            GetProperty2.Statements.Add(new CodeSnippetExpression("whereString += \"[\" + names[i] + \"] = @\" + names[i]"));
            GetProperty2.Statements.Add(new CodeSnippetStatement("}}}"));
            GetProperty2.Statements.Add(new CodeSnippetExpression("System.Data.Common.DbCommand command = Database.GetSqlStringCommand(\"select [\" + targetField + \"] from [\" + " + _dbsAnalysisClass.Name + ".TableName + \"] \" + (string.IsNullOrEmpty(whereString) ? \"\" : \" where \"+whereString))"));
            GetProperty2.Statements.Add(new CodeSnippetStatement("if (names.Length == values.Length){"));
            GetProperty2.Statements.Add(new CodeSnippetStatement("for (int i = 0; i < names.Length; i++){"));
            GetProperty2.Statements.Add(new CodeSnippetExpression("Database.AddInParameter(command, \"\" + names[i], EnumDbTypeDictionary[names[i]], values[i])"));
            GetProperty2.Statements.Add(new CodeSnippetStatement("}}"));
            GetProperty2.Statements.Add(new CodeSnippetExpression("object returnObject = Database.ExecuteScalar(command)"));
            GetProperty2.Statements.Add(new CodeSnippetExpression("command.Dispose()"));
            GetProperty2.Statements.Add(new CodeSnippetExpression("return returnObject"));
            ctd.Members.Add(GetProperty2);
            #endregion 根据条件获取相对属性的值(符合多个条件只返回第一条) 2
            #region 根据条件获取相对属性的值(符合多个条件只返回第一条) 3
            CodeMemberMethod GetProperty3 = new CodeMemberMethod();
            GetProperty3.Comments.Add(new CodeCommentStatement("<summary>", true));
            GetProperty3.Comments.Add(new CodeCommentStatement("根据条件获取相对属性的值(符合多个条件只返回第一条)", true));
            GetProperty3.Comments.Add(new CodeCommentStatement("</summary>", true));
            GetProperty3.Comments.Add(new CodeCommentStatement("<param name=\"targetField\">条件属性</param>", true));
            GetProperty3.Comments.Add(new CodeCommentStatement("<param name=\"whereString\">条件</param>", true));
            GetProperty3.Comments.Add(new CodeCommentStatement("<returns>希望获取的属性的值</returns>", true));
            //GetProperty3.CustomAttributes.Add(new CodeAttributeDeclaration(new CodeTypeReference(typeof(System.ComponentModel.DataObjectMethodAttribute)), new System.CodeDom.CodeAttributeArgument(new System.CodeDom.CodeArgumentReferenceExpression("System.ComponentModel.DataObjectMethodType.Select , true"))));
            GetProperty3.Name = "GetProperty";
            GetProperty3.Attributes = Config.MemberAttribute | MemberAttributes.Static;
            GetProperty3.Parameters.Add(new CodeParameterDeclarationExpression(_dbsAnalysisClass.Name + "Enum", "targetField"));
            GetProperty3.Parameters.Add(new CodeParameterDeclarationExpression(typeof(string), "whereString"));
            GetProperty3.ReturnType = new CodeTypeReference(typeof(object));
            GetProperty3.Statements.Add(new CodeSnippetExpression("System.Data.Common.DbCommand command = Database.GetSqlStringCommand(\"select [\" + targetField + \"] from [\" + " + _dbsAnalysisClass.Name + ".TableName + \"] \" + (string.IsNullOrEmpty(whereString) ? \"\" : \" where \"+whereString))"));
            GetProperty3.Statements.Add(new CodeSnippetExpression("object returnObject = Database.ExecuteScalar(command)"));
            GetProperty3.Statements.Add(new CodeSnippetExpression("command.Dispose()"));
            GetProperty3.Statements.Add(new CodeSnippetExpression("return returnObject"));
            ctd.Members.Add(GetProperty3);
            #endregion 根据条件获取相对属性的值(符合多个条件只返回第一条) 3

            #region 根据条件设置相对属性的值(符合多个条件只返回第一条) 1
            CodeMemberMethod SetProperty1 = new CodeMemberMethod();
            SetProperty1.Comments.Add(new CodeCommentStatement("<summary>", true));
            SetProperty1.Comments.Add(new CodeCommentStatement("根据条件设置相对属性的值(符合多个条件只返回第一条)", true));
            SetProperty1.Comments.Add(new CodeCommentStatement("</summary>", true));
            SetProperty1.Comments.Add(new CodeCommentStatement("<param name=\"name\">条件属性</param>", true));
            SetProperty1.Comments.Add(new CodeCommentStatement("<param name=\"value\">条件值</param>", true));
            SetProperty1.Comments.Add(new CodeCommentStatement("<param name=\"targetname\">要设置的属性</param>", true));
            SetProperty1.Comments.Add(new CodeCommentStatement("<param name=\"targetvalue\">要设置的值</param>", true));
            SetProperty1.Comments.Add(new CodeCommentStatement("<returns>是否成功</returns>", true));
            //GetProperty1.CustomAttributes.Add(new CodeAttributeDeclaration(new CodeTypeReference(typeof(System.ComponentModel.DataObjectMethodAttribute)), new System.CodeDom.CodeAttributeArgument(new System.CodeDom.CodeArgumentReferenceExpression("System.ComponentModel.DataObjectMethodType.Select , true"))));
            SetProperty1.Name = "SetProperty";
            SetProperty1.Attributes = Config.MemberAttribute | MemberAttributes.Static;
            SetProperty1.Parameters.Add(new CodeParameterDeclarationExpression(_dbsAnalysisClass.Name + "Enum", "name"));
            SetProperty1.Parameters.Add(new CodeParameterDeclarationExpression(typeof(object), "value"));
            SetProperty1.Parameters.Add(new CodeParameterDeclarationExpression(_dbsAnalysisClass.Name + "Enum", "targetname"));
            SetProperty1.Parameters.Add(new CodeParameterDeclarationExpression(typeof(object), "targetvalue"));
            SetProperty1.ReturnType = new CodeTypeReference(typeof(bool));
            SetProperty1.Statements.Add(new CodeSnippetExpression("return SetProperty(new " + _dbsAnalysisClass.Name + "Enum[] { name }, new object[] { value }, new " + _dbsAnalysisClass.Name + "Enum[] { targetname }, new object[] { targetvalue })"));
            ctd.Members.Add(SetProperty1);
            #endregion 根据条件设置相对属性的值(符合多个条件只返回第一条) 1

            #region 根据条件设置相对属性的值(符合多个条件只返回第一条) 2
            CodeMemberMethod SetProperty2 = new CodeMemberMethod();
            SetProperty2.Comments.Add(new CodeCommentStatement("<summary>", true));
            SetProperty2.Comments.Add(new CodeCommentStatement("根据条件设置相对属性的值(符合多个条件只返回第一条)", true));
            SetProperty2.Comments.Add(new CodeCommentStatement("</summary>", true));
            SetProperty2.Comments.Add(new CodeCommentStatement("<param name=\"names\">条件属性</param>", true));
            SetProperty2.Comments.Add(new CodeCommentStatement("<param name=\"values\">条件值</param>", true));
            SetProperty2.Comments.Add(new CodeCommentStatement("<param name=\"targetnames\">要设置的属性</param>", true));
            SetProperty2.Comments.Add(new CodeCommentStatement("<param name=\"targetvalues\">要设置的值</param>", true));
            SetProperty2.Comments.Add(new CodeCommentStatement("<returns>是否成功</returns>", true));
            //SetProperty2.CustomAttributes.Add(new CodeAttributeDeclaration(new CodeTypeReference(typeof(System.ComponentModel.DataObjectMethodAttribute)), new System.CodeDom.CodeAttributeArgument(new System.CodeDom.CodeArgumentReferenceExpression("System.ComponentModel.DataObjectMethodType.Select , true"))));
            SetProperty2.Name = "SetProperty";
            SetProperty2.Attributes = Config.MemberAttribute | MemberAttributes.Static;
            SetProperty2.Parameters.Add(new CodeParameterDeclarationExpression(_dbsAnalysisClass.Name + "Enum[]", "names"));
            SetProperty2.Parameters.Add(new CodeParameterDeclarationExpression(typeof(object[]), "values"));
            SetProperty2.Parameters.Add(new CodeParameterDeclarationExpression(_dbsAnalysisClass.Name + "Enum[]", "targetnames"));
            SetProperty2.Parameters.Add(new CodeParameterDeclarationExpression(typeof(object[]), "targetvalues"));
            SetProperty2.ReturnType = new CodeTypeReference(typeof(bool));
            SetProperty2.Statements.Add(new CodeSnippetExpression("string whereString = string.Empty"));
            SetProperty2.Statements.Add(new CodeSnippetStatement("if (names.Length == values.Length){"));
            SetProperty2.Statements.Add(new CodeSnippetStatement("for (int i = 0; i < names.Length; i++){"));
            SetProperty2.Statements.Add(new CodeSnippetStatement("if (values[i] == null){"));
            SetProperty2.Statements.Add(new CodeSnippetExpression("whereString += string.IsNullOrEmpty(whereString) ? \"\" : \" and \""));
            SetProperty2.Statements.Add(new CodeSnippetExpression("whereString += \" [\" + names[i] + \"] is null \""));
            SetProperty2.Statements.Add(new CodeSnippetStatement("}else {"));
            SetProperty2.Statements.Add(new CodeSnippetExpression("whereString += string.IsNullOrEmpty(whereString) ? \"\" : \" and \""));
            SetProperty2.Statements.Add(new CodeSnippetExpression("whereString += \"[\" + names[i] + \"] = @g_\" + names[i]"));
            SetProperty2.Statements.Add(new CodeSnippetStatement("}}}"));

            SetProperty2.Statements.Add(new CodeSnippetExpression("string setString = string.Empty"));
            SetProperty2.Statements.Add(new CodeSnippetStatement("if (targetnames.Length == targetvalues.Length){"));
            SetProperty2.Statements.Add(new CodeSnippetStatement("for (int i = 0; i < targetnames.Length; i++){"));
            SetProperty2.Statements.Add(new CodeSnippetStatement("if (targetvalues[i] == null){"));
            SetProperty2.Statements.Add(new CodeSnippetExpression("setString += string.IsNullOrEmpty(setString) ? \"\" : \" , \""));
            SetProperty2.Statements.Add(new CodeSnippetExpression("setString += \" [\" + targetnames[i] + \"] = null \""));
            SetProperty2.Statements.Add(new CodeSnippetStatement("}else {"));
            SetProperty2.Statements.Add(new CodeSnippetExpression("setString += string.IsNullOrEmpty(setString) ? \"\" : \" , \""));
            SetProperty2.Statements.Add(new CodeSnippetExpression("setString += \"[\" + targetnames[i] + \"] = @s_\" + targetnames[i]"));
            SetProperty2.Statements.Add(new CodeSnippetStatement("}}}"));

            SetProperty2.Statements.Add(new CodeSnippetExpression("System.Data.Common.DbCommand command = Database.GetSqlStringCommand(\"update [\" + " + _dbsAnalysisClass.Name + ".TableName + \"] set \"+ setString +  (string.IsNullOrEmpty(whereString) ? \"\" : \" where \"+whereString))"));
            SetProperty2.Statements.Add(new CodeSnippetStatement("if (names.Length == values.Length){"));
            SetProperty2.Statements.Add(new CodeSnippetStatement("for (int i = 0; i < names.Length; i++){"));
            SetProperty2.Statements.Add(new CodeSnippetExpression("Database.AddInParameter(command, \"g_\" + names[i], EnumDbTypeDictionary[names[i]], values[i])"));
            SetProperty2.Statements.Add(new CodeSnippetStatement("}}"));
            SetProperty2.Statements.Add(new CodeSnippetStatement("if (targetnames.Length == targetvalues.Length){"));
            SetProperty2.Statements.Add(new CodeSnippetStatement("for (int i = 0; i < targetnames.Length; i++){"));
            SetProperty2.Statements.Add(new CodeSnippetExpression("Database.AddInParameter(command, \"s_\" + targetnames[i], EnumDbTypeDictionary[targetnames[i]], targetvalues[i])"));
            SetProperty2.Statements.Add(new CodeSnippetStatement("}}"));
            SetProperty2.Statements.Add(new CodeSnippetExpression("int returnObject = Database.ExecuteNonQuery(command)"));
            SetProperty2.Statements.Add(new CodeSnippetExpression("command.Dispose()"));
            SetProperty2.Statements.Add(new CodeSnippetExpression("return returnObject>0"));
            ctd.Members.Add(SetProperty2);
            #endregion 根据条件设置相对属性的值(符合多个条件只返回第一条) 2
            #region 获得DataSet1
            CodeMemberMethod methodSelectDataSet1 = new CodeMemberMethod();
            methodSelectDataSet1.Comments.Add(new CodeCommentStatement("<summary>", true));
            methodSelectDataSet1.Comments.Add(new CodeCommentStatement("获得DataSet", true));
            methodSelectDataSet1.Comments.Add(new CodeCommentStatement("</summary>", true));
            methodSelectDataSet1.Comments.Add(new CodeCommentStatement("<param name=\"PageSize\">返回数据的行数</param>", true));
            methodSelectDataSet1.Comments.Add(new CodeCommentStatement("<param name=\"PageIndex\">当前页</param>", true));
            methodSelectDataSet1.Comments.Add(new CodeCommentStatement("<param name=\"strWhere\">查询条件</param>", true));
            methodSelectDataSet1.Comments.Add(new CodeCommentStatement("<param name=\"strOrder\">排序</param>", true));
            methodSelectDataSet1.Comments.Add(new CodeCommentStatement("<returns>数据</returns>", true));
            methodSelectDataSet1.CustomAttributes.Add(new CodeAttributeDeclaration(new CodeTypeReference(typeof(System.ComponentModel.DataObjectMethodAttribute)), new System.CodeDom.CodeAttributeArgument(new System.CodeDom.CodeArgumentReferenceExpression("System.ComponentModel.DataObjectMethodType.Select , false"))));
            methodSelectDataSet1.Name = string.Format(Config.DbMemberMethodSelectDataSet, _dbsAnalysisClass.Name);
            methodSelectDataSet1.Attributes = Config.MemberAttribute | MemberAttributes.Static;
            methodSelectDataSet1.Parameters.Add(new CodeParameterDeclarationExpression(typeof(int), "PageSize"));
            methodSelectDataSet1.Parameters.Add(new CodeParameterDeclarationExpression(typeof(int), "PageIndex"));
            methodSelectDataSet1.Parameters.Add(new CodeParameterDeclarationExpression(typeof(string), "strWhere"));
            methodSelectDataSet1.Parameters.Add(new CodeParameterDeclarationExpression(typeof(string), "strOrder"));
            methodSelectDataSet1.ReturnType = new CodeTypeReference(typeof(System.Data.DataSet));
            methodSelectDataSet1.Statements.Add(new CodeSnippetExpression("int CountRows;int CountPage"));
            methodSelectDataSet1.Statements.Add(new CodeSnippetExpression("return " + string.Format(Config.DbMemberMethodSelectDataSet, _dbsAnalysisClass.Name) + "(PageSize,PageIndex,strWhere,strOrder,out CountRows,out CountPage)"));
            ctd.Members.Add(methodSelectDataSet1);
            #endregion 获得DataSet1
            #region 获得DataSet2
            CodeMemberMethod methodSelectDataSet2 = new CodeMemberMethod();
            methodSelectDataSet2.Comments.Add(new CodeCommentStatement("<summary>", true));
            methodSelectDataSet2.Comments.Add(new CodeCommentStatement("获得DataSet", true));
            methodSelectDataSet2.Comments.Add(new CodeCommentStatement("</summary>", true));
            methodSelectDataSet2.Comments.Add(new CodeCommentStatement("<param name=\"PageSize\">返回数据的行数</param>", true));
            methodSelectDataSet2.Comments.Add(new CodeCommentStatement("<param name=\"PageIndex\">当前页</param>", true));
            methodSelectDataSet2.Comments.Add(new CodeCommentStatement("<param name=\"strWhere\">查询条件</param>", true));
            methodSelectDataSet2.Comments.Add(new CodeCommentStatement("<param name=\"strOrder\">排序</param>", true));
            methodSelectDataSet2.Comments.Add(new CodeCommentStatement("<param name=\"CountRows\">记录总数</param>", true));
            methodSelectDataSet2.Comments.Add(new CodeCommentStatement("<param name=\"CountPage\">总页数</param>", true));
            methodSelectDataSet2.Comments.Add(new CodeCommentStatement("<returns>数据</returns>", true));
            methodSelectDataSet2.CustomAttributes.Add(new CodeAttributeDeclaration(new CodeTypeReference(typeof(System.ComponentModel.DataObjectMethodAttribute)), new System.CodeDom.CodeAttributeArgument(new System.CodeDom.CodeArgumentReferenceExpression("System.ComponentModel.DataObjectMethodType.Select , true"))));
            methodSelectDataSet2.Name = string.Format(Config.DbMemberMethodSelectDataSet, _dbsAnalysisClass.Name);
            methodSelectDataSet2.Attributes = Config.MemberAttribute | MemberAttributes.Static;
            methodSelectDataSet2.Parameters.Add(new CodeParameterDeclarationExpression(typeof(int), "PageSize"));
            methodSelectDataSet2.Parameters.Add(new CodeParameterDeclarationExpression(typeof(int), "PageIndex"));
            methodSelectDataSet2.Parameters.Add(new CodeParameterDeclarationExpression(typeof(string), "strWhere"));
            methodSelectDataSet2.Parameters.Add(new CodeParameterDeclarationExpression(typeof(string), "strOrder"));
            CodeParameterDeclarationExpression CountRows = new CodeParameterDeclarationExpression(typeof(int), "CountRows");
            CountRows.Direction = FieldDirection.Out;
            methodSelectDataSet2.Parameters.Add(CountRows);
            CodeParameterDeclarationExpression CountPage = new CodeParameterDeclarationExpression(typeof(int), "CountPage");
            CountPage.Direction = FieldDirection.Out;
            methodSelectDataSet2.Parameters.Add(CountPage);
            methodSelectDataSet2.ReturnType = new CodeTypeReference(typeof(System.Data.DataSet));
            methodSelectDataSet2.Statements.Add(new CodeSnippetExpression("return " + string.Format(Config.DbMemberMethodSelectDataSet, _dbsAnalysisClass.Name) + "(PageSize,PageIndex,\"*\",strWhere,strOrder,out CountRows,out CountPage)"));
            ctd.Members.Add(methodSelectDataSet2);
            #endregion 获得DataSet2
            #region 获得DataSet3
            CodeMemberMethod methodSelectDataSet3 = new CodeMemberMethod();
            methodSelectDataSet3.Comments.Add(new CodeCommentStatement("<summary>", true));
            methodSelectDataSet3.Comments.Add(new CodeCommentStatement("获得DataSet", true));
            methodSelectDataSet3.Comments.Add(new CodeCommentStatement("</summary>", true));
            methodSelectDataSet3.Comments.Add(new CodeCommentStatement("<param name=\"PageSize\">返回数据的行数</param>", true));
            methodSelectDataSet3.Comments.Add(new CodeCommentStatement("<param name=\"PageIndex\">当前页</param>", true));
            methodSelectDataSet3.Comments.Add(new CodeCommentStatement("<param name=\"fieldList\">显示字段</param>", true));
            methodSelectDataSet3.Comments.Add(new CodeCommentStatement("<param name=\"strWhere\">查询条件</param>", true));
            methodSelectDataSet3.Comments.Add(new CodeCommentStatement("<param name=\"strOrder\">排序</param>", true));
            methodSelectDataSet3.Comments.Add(new CodeCommentStatement("<returns>数据</returns>", true));
            methodSelectDataSet3.CustomAttributes.Add(new CodeAttributeDeclaration(new CodeTypeReference(typeof(System.ComponentModel.DataObjectMethodAttribute)), new System.CodeDom.CodeAttributeArgument(new System.CodeDom.CodeArgumentReferenceExpression("System.ComponentModel.DataObjectMethodType.Select , false"))));
            methodSelectDataSet3.Name = string.Format(Config.DbMemberMethodSelectDataSet, _dbsAnalysisClass.Name);
            methodSelectDataSet3.Attributes = Config.MemberAttribute | MemberAttributes.Static;
            methodSelectDataSet3.Parameters.Add(new CodeParameterDeclarationExpression(typeof(int), "PageSize"));
            methodSelectDataSet3.Parameters.Add(new CodeParameterDeclarationExpression(typeof(int), "PageIndex"));
            methodSelectDataSet3.Parameters.Add(new CodeParameterDeclarationExpression(typeof(string), "fieldList"));
            methodSelectDataSet3.Parameters.Add(new CodeParameterDeclarationExpression(typeof(string), "strWhere"));
            methodSelectDataSet3.Parameters.Add(new CodeParameterDeclarationExpression(typeof(string), "strOrder"));
            methodSelectDataSet3.ReturnType = new CodeTypeReference(typeof(System.Data.DataSet));
            methodSelectDataSet3.Statements.Add(new CodeSnippetExpression("int CountRows;int CountPage"));
            methodSelectDataSet3.Statements.Add(new CodeSnippetExpression("return " + string.Format(Config.DbMemberMethodSelectDataSet, _dbsAnalysisClass.Name) + "(PageSize,PageIndex,fieldList,strWhere,strOrder,out CountRows,out CountPage)"));
            ctd.Members.Add(methodSelectDataSet3);
            #endregion 获得DataSet3
            #region 获得DataSet4
            CodeMemberMethod methodSelectDataSet4 = new CodeMemberMethod();
            methodSelectDataSet4.Comments.Add(new CodeCommentStatement("<summary>", true));
            methodSelectDataSet4.Comments.Add(new CodeCommentStatement("获得DataSet", true));
            methodSelectDataSet4.Comments.Add(new CodeCommentStatement("</summary>", true));
            methodSelectDataSet4.Comments.Add(new CodeCommentStatement("<param name=\"PageSize\">返回数据的行数</param>", true));
            methodSelectDataSet4.Comments.Add(new CodeCommentStatement("<param name=\"PageIndex\">当前页</param>", true));
            methodSelectDataSet4.Comments.Add(new CodeCommentStatement("<param name=\"fieldList\">显示字段</param>", true));
            methodSelectDataSet4.Comments.Add(new CodeCommentStatement("<param name=\"strWhere\">查询条件</param>", true));
            methodSelectDataSet4.Comments.Add(new CodeCommentStatement("<param name=\"strOrder\">排序</param>", true));
            methodSelectDataSet4.Comments.Add(new CodeCommentStatement("<param name=\"CountRows\">记录总数</param>", true));
            methodSelectDataSet4.Comments.Add(new CodeCommentStatement("<param name=\"CountPage\">总页数</param>", true));
            methodSelectDataSet4.Comments.Add(new CodeCommentStatement("<returns>数据</returns>", true));
            methodSelectDataSet4.CustomAttributes.Add(new CodeAttributeDeclaration(new CodeTypeReference(typeof(System.ComponentModel.DataObjectMethodAttribute)), new System.CodeDom.CodeAttributeArgument(new System.CodeDom.CodeArgumentReferenceExpression("System.ComponentModel.DataObjectMethodType.Select , false"))));
            methodSelectDataSet4.Name = string.Format(Config.DbMemberMethodSelectDataSet, _dbsAnalysisClass.Name);
            methodSelectDataSet4.Attributes = Config.MemberAttribute | MemberAttributes.Static;
            methodSelectDataSet4.ReturnType = new CodeTypeReference(typeof(System.Data.DataSet));
            methodSelectDataSet4.Parameters.Add(new CodeParameterDeclarationExpression(typeof(int), "PageSize"));
            methodSelectDataSet4.Parameters.Add(new CodeParameterDeclarationExpression(typeof(int), "PageIndex"));
            methodSelectDataSet4.Parameters.Add(new CodeParameterDeclarationExpression(typeof(string), "fieldList"));
            methodSelectDataSet4.Parameters.Add(new CodeParameterDeclarationExpression(typeof(string), "strWhere"));
            methodSelectDataSet4.Parameters.Add(new CodeParameterDeclarationExpression(typeof(string), "strOrder"));
            //CodeParameterDeclarationExpression CountRows = new CodeParameterDeclarationExpression(typeof(int), "CountRows");
            //CountRows.Direction = FieldDirection.Out;
            methodSelectDataSet4.Parameters.Add(CountRows);
            //CodeParameterDeclarationExpression CountPage = new CodeParameterDeclarationExpression(typeof(int), "CountPage");
            //CountPage.Direction = FieldDirection.Out;
            methodSelectDataSet4.Parameters.Add(CountPage);
            methodSelectDataSet4.Statements.Add(new CodeSnippetExpression("return " + string.Format(Config.DbMemberMethodSelectDataSet, _dbsAnalysisClass.Name) + "( TableName ,\"" + _dbsAnalysisClass.ID.SqlName + "\", PageSize, PageIndex, fieldList, strWhere, strOrder, out CountRows, out CountPage)"));
            //methodSelectDataSet4.Statements.Add(new CodeSnippetExpression("CountRows=0;CountPage=0;return null"));
            ctd.Members.Add(methodSelectDataSet4);
            #endregion 获得DataSet4
            #region 获得数据列表1
            CodeMemberMethod methodSelect1 = new CodeMemberMethod();
            methodSelect1.Comments.Add(new CodeCommentStatement("<summary>", true));
            methodSelect1.Comments.Add(new CodeCommentStatement("获得数据列表", true));
            methodSelect1.Comments.Add(new CodeCommentStatement("</summary>", true));
            methodSelect1.Comments.Add(new CodeCommentStatement("<param name=\"PageSize\">返回数据的行数</param>", true));
            methodSelect1.Comments.Add(new CodeCommentStatement("<param name=\"PageIndex\">当前页</param>", true));
            methodSelect1.Comments.Add(new CodeCommentStatement("<param name=\"strWhere\">查询条件</param>", true));
            methodSelect1.Comments.Add(new CodeCommentStatement("<param name=\"strOrder\">排序</param>", true));
            methodSelect1.Comments.Add(new CodeCommentStatement("<returns>数据</returns>", true));
            methodSelect1.CustomAttributes.Add(new CodeAttributeDeclaration(new CodeTypeReference(typeof(System.ComponentModel.DataObjectMethodAttribute)), new System.CodeDom.CodeAttributeArgument(new System.CodeDom.CodeArgumentReferenceExpression("System.ComponentModel.DataObjectMethodType.Select , false"))));
            methodSelect1.Name = string.Format(Config.DbMemberMethodSelect, _dbsAnalysisClass.Name);
            methodSelect1.Attributes = Config.MemberAttribute | MemberAttributes.Static;
            methodSelect1.Parameters.Add(new CodeParameterDeclarationExpression(typeof(int), "PageSize"));
            methodSelect1.Parameters.Add(new CodeParameterDeclarationExpression(typeof(int), "PageIndex"));
            methodSelect1.Parameters.Add(new CodeParameterDeclarationExpression(typeof(string), "strWhere"));
            methodSelect1.Parameters.Add(new CodeParameterDeclarationExpression(typeof(string), "strOrder"));
            methodSelect1.ReturnType = new CodeTypeReference("System.Collections.Generic.List<" + _dbsAnalysisClass.Name + ">");
            methodSelect1.Statements.Add(new CodeSnippetExpression("int CountRows;int CountPage"));
            methodSelect1.Statements.Add(new CodeSnippetExpression("return " + string.Format(Config.DbMemberMethodSelect, _dbsAnalysisClass.Name) + "(PageSize,PageIndex,strWhere,strOrder,out CountRows,out CountPage)"));
            ctd.Members.Add(methodSelect1);
            #endregion 获得数据列表1
            #region 获得数据列表2
            CodeMemberMethod MethodSelect2 = new CodeMemberMethod();
            MethodSelect2.Comments.Add(new CodeCommentStatement("<summary>", true));
            MethodSelect2.Comments.Add(new CodeCommentStatement("获得数据列表", true));
            MethodSelect2.Comments.Add(new CodeCommentStatement("</summary>", true));
            MethodSelect2.Comments.Add(new CodeCommentStatement("<param name=\"PageSize\">返回数据的行数</param>", true));
            MethodSelect2.Comments.Add(new CodeCommentStatement("<param name=\"PageIndex\">当前页</param>", true));
            MethodSelect2.Comments.Add(new CodeCommentStatement("<param name=\"strWhere\">查询条件</param>", true));
            MethodSelect2.Comments.Add(new CodeCommentStatement("<param name=\"strOrder\">排序</param>", true));
            MethodSelect2.Comments.Add(new CodeCommentStatement("<param name=\"CountRows\">记录总数</param>", true));
            MethodSelect2.Comments.Add(new CodeCommentStatement("<param name=\"CountPage\">总页数</param>", true));
            MethodSelect2.Comments.Add(new CodeCommentStatement("<returns>数据</returns>", true));
            MethodSelect2.CustomAttributes.Add(new CodeAttributeDeclaration(new CodeTypeReference(typeof(System.ComponentModel.DataObjectMethodAttribute)), new System.CodeDom.CodeAttributeArgument(new System.CodeDom.CodeArgumentReferenceExpression("System.ComponentModel.DataObjectMethodType.Select , true"))));
            MethodSelect2.Name = string.Format(Config.DbMemberMethodSelect, _dbsAnalysisClass.Name);
            MethodSelect2.Attributes = Config.MemberAttribute | MemberAttributes.Static;
            MethodSelect2.Parameters.Add(new CodeParameterDeclarationExpression(typeof(int), "PageSize"));
            MethodSelect2.Parameters.Add(new CodeParameterDeclarationExpression(typeof(int), "PageIndex"));
            MethodSelect2.Parameters.Add(new CodeParameterDeclarationExpression(typeof(string), "strWhere"));
            MethodSelect2.Parameters.Add(new CodeParameterDeclarationExpression(typeof(string), "strOrder"));
             CountRows = new CodeParameterDeclarationExpression(typeof(int), "CountRows");
            CountRows.Direction = FieldDirection.Out;
            MethodSelect2.Parameters.Add(CountRows);
             CountPage = new CodeParameterDeclarationExpression(typeof(int), "CountPage");
            CountPage.Direction = FieldDirection.Out;
            MethodSelect2.Parameters.Add(CountPage);
            MethodSelect2.ReturnType = new CodeTypeReference("System.Collections.Generic.List<" + _dbsAnalysisClass.Name + ">");
            MethodSelect2.Statements.Add(new CodeSnippetExpression("return " + string.Format(Config.DbMemberMethodSelect, _dbsAnalysisClass.Name) + "(PageSize,PageIndex,\"*\",strWhere,strOrder,out CountRows,out CountPage)"));
            ctd.Members.Add(MethodSelect2);
            #endregion 获得数据列表2
            #region 获得数据列表3
            CodeMemberMethod MethodSelect3 = new CodeMemberMethod();
            MethodSelect3.Comments.Add(new CodeCommentStatement("<summary>", true));
            MethodSelect3.Comments.Add(new CodeCommentStatement("获得数据列表", true));
            MethodSelect3.Comments.Add(new CodeCommentStatement("</summary>", true));
            MethodSelect3.Comments.Add(new CodeCommentStatement("<param name=\"PageSize\">返回数据的行数</param>", true));
            MethodSelect3.Comments.Add(new CodeCommentStatement("<param name=\"PageIndex\">当前页</param>", true));
            MethodSelect3.Comments.Add(new CodeCommentStatement("<param name=\"fieldList\">显示字段</param>", true));
            MethodSelect3.Comments.Add(new CodeCommentStatement("<param name=\"strWhere\">查询条件</param>", true));
            MethodSelect3.Comments.Add(new CodeCommentStatement("<param name=\"strOrder\">排序</param>", true));
            MethodSelect3.Comments.Add(new CodeCommentStatement("<returns>数据</returns>", true));
            MethodSelect3.CustomAttributes.Add(new CodeAttributeDeclaration(new CodeTypeReference(typeof(System.ComponentModel.DataObjectMethodAttribute)), new System.CodeDom.CodeAttributeArgument(new System.CodeDom.CodeArgumentReferenceExpression("System.ComponentModel.DataObjectMethodType.Select , false"))));
            MethodSelect3.Name = string.Format(Config.DbMemberMethodSelect, _dbsAnalysisClass.Name);
            MethodSelect3.Attributes = Config.MemberAttribute | MemberAttributes.Static;
            MethodSelect3.Parameters.Add(new CodeParameterDeclarationExpression(typeof(int), "PageSize"));
            MethodSelect3.Parameters.Add(new CodeParameterDeclarationExpression(typeof(int), "PageIndex"));
            MethodSelect3.Parameters.Add(new CodeParameterDeclarationExpression(typeof(string), "fieldList"));
            MethodSelect3.Parameters.Add(new CodeParameterDeclarationExpression(typeof(string), "strWhere"));
            MethodSelect3.Parameters.Add(new CodeParameterDeclarationExpression(typeof(string), "strOrder"));
            MethodSelect3.ReturnType = new CodeTypeReference("System.Collections.Generic.List<" + _dbsAnalysisClass.Name + ">");
            MethodSelect3.Statements.Add(new CodeSnippetExpression("int CountRows;int CountPage"));
            MethodSelect3.Statements.Add(new CodeSnippetExpression("return " + string.Format(Config.DbMemberMethodSelect, _dbsAnalysisClass.Name) + "(PageSize,PageIndex,fieldList,strWhere,strOrder,out CountRows,out CountPage)"));
            ctd.Members.Add(MethodSelect3);
            #endregion 获得数据列表3
            #region 获得数据列表4
            CodeMemberMethod MethodSelect4 = new CodeMemberMethod();
            MethodSelect4.Comments.Add(new CodeCommentStatement("<summary>", true));
            MethodSelect4.Comments.Add(new CodeCommentStatement("获得数据列表", true));
            MethodSelect4.Comments.Add(new CodeCommentStatement("</summary>", true));
            MethodSelect4.Comments.Add(new CodeCommentStatement("<param name=\"PageSize\">返回数据的行数</param>", true));
            MethodSelect4.Comments.Add(new CodeCommentStatement("<param name=\"PageIndex\">当前页</param>", true));
            MethodSelect4.Comments.Add(new CodeCommentStatement("<param name=\"fieldList\">显示字段</param>", true));
            MethodSelect4.Comments.Add(new CodeCommentStatement("<param name=\"strWhere\">查询条件</param>", true));
            MethodSelect4.Comments.Add(new CodeCommentStatement("<param name=\"strOrder\">排序</param>", true));
            MethodSelect4.Comments.Add(new CodeCommentStatement("<param name=\"CountRows\">记录总数</param>", true));
            MethodSelect4.Comments.Add(new CodeCommentStatement("<param name=\"CountPage\">总页数</param>", true));
            MethodSelect4.Comments.Add(new CodeCommentStatement("<returns>数据</returns>", true));
            MethodSelect4.CustomAttributes.Add(new CodeAttributeDeclaration(new CodeTypeReference(typeof(System.ComponentModel.DataObjectMethodAttribute)), new System.CodeDom.CodeAttributeArgument(new System.CodeDom.CodeArgumentReferenceExpression("System.ComponentModel.DataObjectMethodType.Select , false"))));
            MethodSelect4.Name = string.Format(Config.DbMemberMethodSelect, _dbsAnalysisClass.Name);
            MethodSelect4.Attributes = Config.MemberAttribute | MemberAttributes.Static;
            MethodSelect4.ReturnType = new CodeTypeReference("System.Collections.Generic.List<" + _dbsAnalysisClass.Name + ">");
            MethodSelect4.Parameters.Add(new CodeParameterDeclarationExpression(typeof(int), "PageSize"));
            MethodSelect4.Parameters.Add(new CodeParameterDeclarationExpression(typeof(int), "PageIndex"));
            MethodSelect4.Parameters.Add(new CodeParameterDeclarationExpression(typeof(string), "fieldList"));
            MethodSelect4.Parameters.Add(new CodeParameterDeclarationExpression(typeof(string), "strWhere"));
            MethodSelect4.Parameters.Add(new CodeParameterDeclarationExpression(typeof(string), "strOrder"));
            //CodeParameterDeclarationExpression CountRows = new CodeParameterDeclarationExpression(typeof(int), "CountRows");
            //CountRows.Direction = FieldDirection.Out;
            MethodSelect4.Parameters.Add(CountRows);
            //CodeParameterDeclarationExpression CountPage = new CodeParameterDeclarationExpression(typeof(int), "CountPage");
            //CountPage.Direction = FieldDirection.Out;
            MethodSelect4.Parameters.Add(CountPage);
            MethodSelect4.Statements.Add(new CodeSnippetExpression("return " + string.Format(Config.DbMemberMethodSelect, _dbsAnalysisClass.Name) + "( TableName ,\"" + _dbsAnalysisClass.ID.SqlName + "\", PageSize, PageIndex, fieldList, strWhere, strOrder, out CountRows, out CountPage)"));
            //MethodSelect4.Statements.Add(new CodeSnippetExpression("CountRows=0;CountPage=0;return null"));
            ctd.Members.Add(MethodSelect4);
            #endregion 获得数据列表4
            #region 获得数据列表总行数
            CodeMemberMethod MethodSelectCount = new CodeMemberMethod();
            MethodSelectCount.Comments.Add(new CodeCommentStatement("<summary>", true));
            MethodSelectCount.Comments.Add(new CodeCommentStatement("获得数据列表总行数", true));
            MethodSelectCount.Comments.Add(new CodeCommentStatement("</summary>", true));
            MethodSelectCount.Comments.Add(new CodeCommentStatement("<param name=\"strWhere\">查询条件</param>", true));
            MethodSelectCount.Comments.Add(new CodeCommentStatement("<returns>行数</returns>", true));
            MethodSelectCount.Name = string.Format(Config.DbMemberMethodSelectCount, _dbsAnalysisClass.Name);
            MethodSelectCount.Attributes = Config.MemberAttribute | MemberAttributes.Static;
            MethodSelectCount.Parameters.Add(new CodeParameterDeclarationExpression(typeof(string), "strWhere"));
            MethodSelectCount.ReturnType = new CodeTypeReference(typeof(int));
            MethodSelectCount.Statements.Add(new CodeSnippetExpression("return " + string.Format(Config.DbMemberMethodSelectCount, _dbsAnalysisClass.Name) + "( TableName ,strWhere)"));
            ctd.Members.Add(MethodSelectCount);
            #endregion 获得数据列表总行数
            #region 特殊查询
            CodeMemberMethod MethodSelectData1 = new CodeMemberMethod();
            MethodSelectData1.Comments.Add(new CodeCommentStatement("<summary>", true));
            MethodSelectData1.Comments.Add(new CodeCommentStatement("特殊查询", true));
            MethodSelectData1.Comments.Add(new CodeCommentStatement("</summary>", true));
            //MethodSelectData1.Comments.Add(new CodeCommentStatement("<param name=\"fieldList\">查询字段，以逗号</param>", true));
            MethodSelectData1.Comments.Add(new CodeCommentStatement("<param name=\"strWhere\">查询条件</param>", true));
            MethodSelectData1.Comments.Add(new CodeCommentStatement("<returns>读取的数据</returns>", true));
            MethodSelectData1.Name = "SelectData";
            MethodSelectData1.Attributes = Config.MemberAttribute | MemberAttributes.Static;
            //MethodSelectData1.Parameters.Add(new CodeParameterDeclarationExpression(typeof(string), "fieldList"));
            MethodSelectData1.Parameters.Add(new CodeParameterDeclarationExpression(typeof(string), "strWhere"));
            MethodSelectData1.ReturnType = new CodeTypeReference(typeof(System.Collections.Generic.List<System.Collections.Generic.Dictionary<string, object>>));
            MethodSelectData1.Statements.Add(new CodeSnippetStatement(@"
            System.Data.IDataReader reader = " + _dbsAnalysisClass.Name + @".Database.ExecuteReader(System.Data.CommandType.Text, strWhere);
            System.Collections.Generic.List<System.Collections.Generic.Dictionary<string, object>> dictionary = new System.Collections.Generic.List<System.Collections.Generic.Dictionary<string, object>>();
            while (reader.Read())
            {
                System.Collections.Generic.Dictionary<string, object> item = new System.Collections.Generic.Dictionary<string, object>();
//                foreach (string  s in fieldList.Split(','))
//                {
//                    if (string.IsNullOrEmpty(s)) { continue; }
//                    item[s] = reader[s] == System.DBNull.Value ? new object() :  reader[s];
//                }
                for (int i = 0; i < reader.FieldCount; i++)
                {
                    string s = reader.GetName(i);
                    item[s.ToLower()] = reader[s] == System.DBNull.Value ? new object() : reader[s];
                }
                dictionary.Add(item);
            }
            return dictionary;"));
            ctd.Members.Add(MethodSelectData1);
            #endregion 特殊查询

            #region GetDataForSelectData
            CodeMemberMethod GetDataForSelectData = new CodeMemberMethod();
            GetDataForSelectData.Comments.Add(new CodeCommentStatement("<summary>", true));
            GetDataForSelectData.Comments.Add(new CodeCommentStatement("获取特殊查询中的数据", true));
            GetDataForSelectData.Comments.Add(new CodeCommentStatement("</summary>", true));
            GetDataForSelectData.Comments.Add(new CodeCommentStatement("<param name=\"DataItem\"></param>", true));
            GetDataForSelectData.Comments.Add(new CodeCommentStatement("<param name=\"Key\"></param>", true));
            GetDataForSelectData.Comments.Add(new CodeCommentStatement("<returns>读取的数据</returns>", true));
            GetDataForSelectData.Name = "GetDataForSelectData";
            GetDataForSelectData.Attributes = Config.MemberAttribute | MemberAttributes.Static;
            GetDataForSelectData.Parameters.Add(new CodeParameterDeclarationExpression(typeof(object), "DataItem"));
            GetDataForSelectData.Parameters.Add(new CodeParameterDeclarationExpression(typeof(string), "Key"));
            GetDataForSelectData.ReturnType = new CodeTypeReference(typeof(object));
            GetDataForSelectData.Statements.Add(new CodeSnippetStatement(@"return ((System.Collections.Generic.Dictionary<string, object>)DataItem)[Key.ToLower()];"));
            ctd.Members.Add(GetDataForSelectData);
            #endregion GetDataForSelectData
            #endregion
            this._dbsAnalysisClass.Namespace.GetNamespace().Types.Add(ctd);


            this.CreateTable(ctd);
            this.Insert(ctd);
            this.Update(ctd);
            this.InsertUpdate(ctd);
            this.DeleteByIndex(ctd);
            this.DeleteByWhere(ctd);
            this.Get1(ctd);
            this.Get2(ctd);
            this.SelectCount(ctd);
            this.SelectDataSet(ctd);
            this.SelectData(ctd);
            this.Exists(ctd);
            this.GetMaxId(ctd);
            this.SelectItems(ctd);
        }

        protected void reader(CodeMemberMethod Method, MaoCaiJun.DataBase.Configuration.DbsAnalysis.Property dbsAnalysisField)
        {
            if (dbsAnalysisField.Type == "System.String")
            {//temp.Id = dcc.Contains("") ? (reader["Id"] == System.DBNull.Value ? System.String.Empty : System.Convert.ToString(reader["Id"])) : System.String.Empty;
                Method.Statements.Add(new CodeSnippetExpression("temp." + dbsAnalysisField.Name + dbsAnalysisField.Type.Replace("System.", " = dcc.Contains(\"" + dbsAnalysisField.SqlName + "\") ? (reader[\"" + dbsAnalysisField.SqlName + "\"] == System.DBNull.Value ? System.String.Empty : System.Convert.To") + "(reader[\"" + dbsAnalysisField.SqlName + "\"])):System.String.Empty"));
            }
            else if (dbsAnalysisField.Type == "System.Byte[]")
            {
                Method.Statements.Add(new CodeSnippetExpression("temp." + dbsAnalysisField.Name + dbsAnalysisField.Type.Replace("System.", " = dcc.Contains(\"" + dbsAnalysisField.SqlName + "\") ? (reader[\"" + dbsAnalysisField.SqlName + "\"] == System.DBNull.Value ? new System.") + dbsAnalysisField.Type.Replace("System.", "{} : (System.") + ")reader[\"" + dbsAnalysisField.SqlName + "\"]):new " + dbsAnalysisField.Type+ "{}"));
            }
            else
            { 
                Method.Statements.Add(new CodeSnippetExpression("temp." + dbsAnalysisField.Name + dbsAnalysisField.Type.Replace("System.", " = dcc.Contains(\"" + dbsAnalysisField.SqlName + "\") ? (reader[\"" + dbsAnalysisField.SqlName + "\"] == System.DBNull.Value ? new System.") + dbsAnalysisField.Type.Replace("System.", "() : System.Convert.To") + "(reader[\"" + dbsAnalysisField.SqlName + "\"])):new " + dbsAnalysisField.Type + "()"));
            }
            //Method.Statements.Add(new CodeSnippetExpression("temp." + dbsAnalysisField.Name +  dbsAnalysisField.Type.Replace("System."," = System.Convert.To") + "(reader[\"" + dbsAnalysisField.SqlName + "\"])"));           
        }

        protected void SetParameter(CodeMemberMethod method, string command)
        {
            method.Statements.Add(new CodeSnippetExpression("Database.AddInParameter(" + command + ", \"" + _dbsAnalysisClass.ID.SqlName + "\", " + GetDbType(_dbsAnalysisClass.ID.Type) + ", model." + _dbsAnalysisClass.ID.Name + ")"));
            foreach (MaoCaiJun.DataBase.Configuration.DbsAnalysis.Property item in _dbsAnalysisClass.Property)
            {
                if (item.Type == "System.DateTime")
                {
                    //System.Data.DbType.Date     model.RefundDate < System.Data.SqlTypes.SqlDateTime.MinValue.Value ? System.Data.SqlTypes.SqlDateTime.MinValue.Value : (model.RefundDate > System.Data.SqlTypes.SqlDateTime.MaxValue.Value ? System.Data.SqlTypes.SqlDateTime.MaxValue.Value : model.RefundDate)
                    method.Statements.Add(new CodeSnippetExpression("Database.AddInParameter(" + command + ", \"" + item.SqlName + "\"," + GetDbType(item.Type) + ",model." + item.Name + " < System.Data.SqlTypes.SqlDateTime.MinValue.Value ? System.Data.SqlTypes.SqlDateTime.MinValue.Value : (model." + item.Name + " > System.Data.SqlTypes.SqlDateTime.MaxValue.Value ? System.Data.SqlTypes.SqlDateTime.MaxValue.Value : model." + item.Name + "))"));
                }
                
                else
                {
                    method.Statements.Add(new CodeSnippetExpression("Database.AddInParameter(" + command + ", \"" + item.SqlName + "\"," + GetDbType(item.Type) + ", model." + item.Name + ")"));
                }
            }
        }

        protected string GetDbType(string str)
        {
            string rStr = string.Empty;
            if (str == "System.DateTime")
            {
                rStr = "System.Data.DbType.Date";
            }
            else if (str == "System.Byte[]")
            {
                rStr = "System.Data.DbType.Binary";
            }
            else
            {
                rStr = str.Replace("System", "System.Data.DbType");
            }
           
            return rStr;
        }

        #region 静态方法
    /// <summary>
        /// 创建数据表
    /// </summary>
    /// <param name="ctd"></param>
        protected abstract void CreateTable(CodeTypeDeclaration ctd);
        /// <summary>
        /// 插入一条数据
        /// </summary>
        /// <param name="ctd"></param>
        protected abstract void Insert(CodeTypeDeclaration ctd);
        protected abstract void Update(CodeTypeDeclaration ctd);
        protected abstract void InsertUpdate(CodeTypeDeclaration ctd);
        protected abstract void DeleteByIndex(CodeTypeDeclaration ctd);
        protected abstract void DeleteByWhere(CodeTypeDeclaration ctd);
        protected abstract void Get1(CodeTypeDeclaration ctd);
        protected abstract void Get2(CodeTypeDeclaration ctd);
        protected abstract void SelectCount(CodeTypeDeclaration ctd);
        protected abstract void SelectDataSet(CodeTypeDeclaration ctd);
        protected abstract void SelectData(CodeTypeDeclaration ctd);
        protected abstract void Exists(CodeTypeDeclaration ctd);
        protected abstract void GetMaxId(CodeTypeDeclaration ctd);
        protected abstract void SelectItems(CodeTypeDeclaration ctd);
        
        #endregion 静态方法
    }

}
